<%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" %>
<%@ page import="javax.naming.Context"%> 
<%@ page import="javax.sql.DataSource"%> 
<%@ page import="javax.naming.InitialContext"%> 
<%@ page import="java.sql.*"%> 
<%@page import="dataconn.dataconn"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@include file="../JS/adminsession.jsp" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登录BugFree</title>
<link href="../css/background.css" rel="stylesheet" type="text/css" />
</head>
 <BODY id=css-zen-garden>
<DIV id=container>
<DIV id=intro>
<DIV id=quickSummary>
<P class=p2>欢迎，<%=session.getAttribute("RealName") %>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../JS/Logout.jsp">退出</a>&nbsp;&nbsp;&nbsp;<a href="../EditUser.jsp">修改资料</a>&nbsp;&nbsp;&nbsp;<a href="../MyBug.jsp">返回前台</a></P>
</DIV>
<DIV id=newuser>
<H3><SPAN>添加用户</SPAN></H3>
  <form action="user_save.jsp" method="post" name="userform">
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="table_style">
  <tr bgcolor="#52514E">
    <td colspan="2" align="center">添加一个用户</td>
    </tr>
  <tr bgcolor="#52514E">
    <td width="30%">用户名</td>
    <td align="left">
      <input name="UserName" type="text" class="selectlist1" id="UserName" />    </td>
  </tr>
  <tr bgcolor="#52514E">
    <td width="30%">密码</td>
    <td align="left"><input name="Password" type="password" class="selectlist1" id="Password" /></td>
  </tr>
  <tr bgcolor="#52514E">
    <td width="30%">真实姓名</td>
    <td align="left">
      <label>
      <input name="RealName" type="text" class="selectlist1" id="RealName2" />
      </label>    </td>
  </tr>
  <tr bgcolor="#52514E">
    <td width="30%">E-mail</td>
    <td align="left">
      <input name="Email" type="text" class="selectlist1" id="Email" />   </td>
  </tr>
  <tr bgcolor="#52514E">
    <td colspan="2">
        <input type="submit" name="button" value="添加" />    </td>
    </tr>
</table>
</form>
  
</DIV></DIV>
<DIV id=supportingText>
  <DIV id=userlist>
<H3><SPAN>用户列表</SPAN></H3>
<form method="post" action="#">
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="table_style">
  <tr bgcolor="#52514E">
    <td colspan="5">所有用户列表<a></a></td>
    </tr>
  <tr bgcolor="#52514E">
    <td>用户名</td>
    <td>真实姓名</td>
    <td>分组</td>
    <td>&nbsp;</td>
  </tr>
 <%
int page_persize=5;//每页显示记录数
int page_total=0;//总的页数
int page_now=1;//当前页码
int rs_total=0;//总的记录数
//用户
dataconn con=new dataconn();
String sql="select UserID,UserName,RealName,AddedById from TestUser where IsDropped=0 ";
ResultSet rs=con.executeQuery(sql); 
rs.last();//指针到最后一条记录
rs_total=rs.getRow();//读出当前行号即总的记录数
//计算总页数
if (rs_total % page_persize==0)
page_total=rs_total/page_persize;
else
page_total=rs_total/page_persize+1; 

//得到当前的页码
try{
	if (!(request.getParameter("page_now")==null || request.getParameter("page_now").equals("")))
	page_now=Math.min(Math.abs(Integer.parseInt(request.getParameter("page_now"))),page_total);
}catch(java.lang.NumberFormatException e){
	out.print("指定页码格式不正确"+e);
}
if (page_now==0) page_now=1;
rs.absolute((page_now-1)*page_persize+1);
if (rs==null) 
out.print("对不起，暂时没有数据!");
else{
	for(int i=1;i<=page_persize;i++)
	{
	String UserID=rs.getString("UserID");
	String UserName=rs.getString("UserName");			
	String RealName=rs.getString("RealName");
	String AddedById=rs.getString("AddedById");	
%>
  <tr bgcolor="#52514E">
  <td><%=UserName %></td>
    <td><%=RealName %></td>   
     <td> <select name="select" class="selectlist2">
<%
String sql1="select GroupName from TestGroup,Group_User where Group_User.GroupID=TestGroup.GroupID and Group_User.UserID="+UserID;
ResultSet rs1=con.executeQuery(sql1);
if(rs1==null)
{%>
      <option></option>
<%}
else{
{
   while(rs1.next())
   {
%>
    <option><%=rs1.getString("GroupName")%></option>

<%} 
}
}

 %>
     </select></td>
    <td><a href="user_del.jsp?UserID=<%=UserID%>">删除</a></td>
 <%
if (!rs.next()) break;
	}
}
rs.close();
%>
 <p align=center>
<%
//显示页码导航，其中的问号表示由当前页面处理。
out.print("总共"+rs_total+"条记录　");
if (page_total>1){
out.print("当前第"+page_now+"页　");
out.print("共"+page_total+"页　");
if(page_now!=1) {
		out.print("<a href=?page_now=1>首页</a>　");
		out.print("<a href=?page_now="+(page_now-1)+">上一页</a>　");
	}
if(page_now!=page_total){
	out.print("<a href=?page_now="+(page_now+1)+">下一页</a>　"); 
	out.print("<a href=?page_now="+page_total+">尾页</a>　");
	} 
%>
<form action="#" method="post"><!--问号表示由当前页面处理 -->
	<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
	  <tr>
		<td><div align="center">跳转到：
		  <input name="page_now" type="text" size="3" />
				<input name="submit" type="submit" value="提交" />
		</div></td>
	  </tr>
	</table>
</form>
</tr>

<% } %>
</table></form>
</DIV>
</DIV>
<DIV id=linkList>
<DIV id=linkList2>
<DIV id=lusers>
<H3 class=users></H3>
<UL>
  <LI><a href="GroupMaintain.jsp"><SPAN 
  class=accesskey>浏览/维护分组</apan></a> </li> 
  <LI><A href="AddGroup.jsp"><SPAN 
  class=accesskey>添加新的分组</SPAN></A> </LI> 
    <LI><A href="AddUser.jsp"><SPAN 
  class=accesskey>浏览/维护用户</SPAN></A> </LI> 
  </UL>
</DIV>
<DIV id=lprojects>
<H3 class=projects></H3>
<UL>
    <LI><A href="NewProject.jsp"><SPAN 
  class=accesskey>新建项目</SPAN></A> </LI> 
<script> 
function go(obj){ 
self.location=obj.options[obj.selectedIndex].value; 
return false; 
} 
</script> 
        <LI>
        <form  method="post" action="ManageProject.jsp">
          <select name="project" class="treelist"  onchange="go(this)" >
            <option selected="selected">维护项目</option>
   <%
   String sql2="select ProjectName,ProjectID from TestProject where IsDropped='0'";
   ResultSet rs2=con.executeQuery(sql2);

   while(rs2.next())
   {
      String ProjectID=rs2.getString("ProjectID");
      String ProjectName=rs2.getString("ProjectName");
   %>
            <option value="ManageProject.jsp?ProjectID=<%=ProjectID%>"><%=ProjectName%></option>
            <%} %>
 <%
    rs2.close();
    con.closeConn();
    con.closeStmt(); 
 %>
          </select>
        </form>
      </LI>
</UL>
</DIV></DIV></DIV></DIV>
</BODY>
</html>
 